package com.noah.project.controller

import com.noah.project.global.Const
import com.noah.project.model.Career
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner

@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class CareerApiControllerTest {
    @Autowired
    lateinit var careerApiController: CareerApiController

    /*****************日记******************/
    @Test
    @Throws(Exception::class)
    fun addCareer() {
        val career = Career(coid= 1,aid = 1065, title = "剑圣2", content = "内容内容", duty = "主宰",timeStart= 1, timeEnd = System.currentTimeMillis())
        val reply = careerApiController.addCareer(career, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun deleteCareer() {
        val career = Career()
        career.caid = 32
        val reply = careerApiController.deleteCareer(career, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun deleteCareerByAid() {
        val company = Career()
        company.aid = 1065
        val reply = careerApiController.deleteCareer(company, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun updateCareer() {
        val career = Career(coid=2, caid = 32, title = "剑圣", content = "升级啦啦啦", duty = "主宰",timeStart= 1, timeEnd = System.currentTimeMillis())
        val reply = careerApiController.updateCareer(career = career, token = Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun getCareer() {
        val reply = careerApiController.getCareer(caid = 32, token = Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun getAllCareers() {
        val reply = careerApiController.getCareerList(aid = 1065)
        println(reply.toString())
    }
}
